package com.selangshiwo.sina.biz;

import com.selangshiwo.Util;
import com.selangshiwo.sina.httpclient.SinaHttpClient;
import com.selangshiwo.sina.requst.WeiboSendMsgRequestPack;
import com.selangshiwo.sina.result.ResultPack;
import com.selangshiwo.sina.result.WeiboSendMsgResultPack;

public class WeiboSendMsgBiz implements IBaseHttpBiz{

	private String msgText = "";
	private String code = "-1000";
	
	public WeiboSendMsgBiz(){
		
	}
	
	public void setMsgText(String msg){
		this.msgText = msg ;
	}
	
	public String getMsgText(){
		return this.msgText ;
	}
	
	public String getResultCode(){
		return this.code ;
	}
	
	@Override
	public ResultPack run() {
		
		WeiboSendMsgRequestPack request = new WeiboSendMsgRequestPack();
		try {
			request.setMsgContent(this.getMsgText());
			WeiboSendMsgResultPack result = (WeiboSendMsgResultPack)SinaHttpClient.getInstance().
					postRequest(request, WeiboSendMsgResultPack.class);
			
			this.code = (String)result.getJson().get("code");
			
			return result ;
		} catch (Exception e) {
			Util.err(e.getMessage());
			//e.printStackTrace();
		}
		
		return null;
	}

}
